// ajax的预处理，每个ajax请求都要调用这个方法
$.ajaxPrefilter(function(options, originalOptions, jqXHR) {
    options.url = "http://www.liulongbin.top:3007" + options.url;

    // 给有权限的接口设置请求头
    if (options.url.includes("/my")) {
        options.headers = {
            Authorization: localStorage.getItem("token"),
        };
    }
    options.complete = function(xhr) {
        var res = xhr.responseJSON;
        if (res.status === 1 && res.message === "身份认证失败！") {
            location.href = "./login.html";
            localStorage.removeItem("token");
        }
    };
});